package com.coffee_shop_app.module.http;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import javax.annotation.Nullable;

public class MyNanoHttpService extends Service {

    private MyNanoHttpdServer httpServer = MyNanoHttpdServer.getInstance(null, null);

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        try {
            httpServer.start();
        } catch (Exception e) {
            e.printStackTrace();
            startService(new Intent(this,MyNanoHttpService.class));
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId){

        return super.onStartCommand(intent, flags, startId);
    }

    public void onDestroy() {
        httpServer.stop();
    }
}